from django.shortcuts import render

# Create your views here.
from rest_framework.generics import ListAPIView, RetrieveAPIView
from rest_framework_extensions.cache.mixins import ListCacheResponseMixin, RetrieveCacheResponseMixin

from areas import serializers
from areas.models import Areas


class AreasView(ListCacheResponseMixin, ListAPIView):
    """获取省级区域信息"""
    queryset = Areas.objects.filter(parent=None)
    serializer_class = serializers.AreasSerializer


class SubAreasView(RetrieveCacheResponseMixin, RetrieveAPIView):
    queryset = Areas.objects.all()
    serializer_class = serializers.SubAreasSerializer
